package com.powernode.lambda.lambda;

import com.powernode.lambda.Student;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

/**
 * 自己定义函数式接口
 */
public class Lambda02 {
    public static void main(String[] args) {
        Type1 ob1 = a -> (a & 1) == 0;
        Type1 ob2 = a -> BigInteger.valueOf(a).isProbablePrime(100);
        Type2 ob3 = (a, b, c) -> a + b + c;
        Type3 ob4 = (a, b) -> a - b;
        Type3 ob5 = (a, b) -> a * b;
        Type4<Student> ob6 = () -> new Student();
        Type4<List<Student>> ob7 = () -> new ArrayList<Student>();
        Type7<Student,String>  ob8 = s -> s.getName();
        Type7<Student,Integer> ob9 = s -> s.getAge();
    }

    @FunctionalInterface
    interface Type1{
        boolean rt(int a);
    }

    @FunctionalInterface
    interface Type2{
        int rt(int a, int b, int c);
    }

    @FunctionalInterface
    interface Type3{
        int rt(int a, int b);
    }

//    interface Type4{
//        Student rt();
//    }
    @FunctionalInterface
    interface Type4<T>{
        T rt();
    }

//    interface Type7{
//        int rt(Student student);
//    }

    @FunctionalInterface
    interface Type7<I,O>{
        O rt(I student);
    }

}
